<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">

    <ui:composition template="/template/template.xhtml">
        <ui:define name="title">
            <h:outputText value="#{bundle.ListReservationTitle}"></h:outputText>
        </ui:define>
        <ui:define name="content">
            <h:form styleClass="list_form">
                <h:panelGroup id="messagePanel" layout="block">
                    <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
                </h:panelGroup>
                <h:outputText escape="false" value="#{bundle.ListReservationEmpty}" rendered="#{reservationController.items.rowCount == 0}"/>
                <h:panelGroup rendered="#{reservationController.items.rowCount > 0}">
                    <h:outputText value="#{reservationController.pagination.pageFirstItem + 1}..#{reservationController.pagination.pageLastItem + 1}/#{reservationController.pagination.itemsCount}"/>&nbsp;
                    <h:commandLink action="#{reservationController.previous}" value="#{bundle.Previous} #{reservationController.pagination.pageSize}" rendered="#{reservationController.pagination.hasPreviousPage}"/>&nbsp;
                    <h:commandLink action="#{reservationController.next}" value="#{bundle.Next} #{reservationController.pagination.pageSize}" rendered="#{reservationController.pagination.hasNextPage}"/>&nbsp;
                    <h:dataTable value="#{reservationController.items}" var="item" border="0" cellpadding="2" cellspacing="0" rowClasses="odd_row,even_row" rules="all" style="border:solid 1px">
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListReservationTitle_id}"/>
                            </f:facet>
                            <h:outputText value="#{item.id}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListReservationTitle_room}"/>
                            </f:facet>
                            <h:outputText value="#{item.room}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListReservationTitle_client}"/>
                            </f:facet>
                            <h:outputText value="#{item.user}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListReservationTitle_reservationBegin}"/>
                            </f:facet>
                            <h:outputText value="#{item.reservationBegin}">
                                <f:convertDateTime pattern="MM/dd/yyyy" />
                            </h:outputText>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListReservationTitle_reservationEnd}"/>
                            </f:facet>
                            <h:outputText value="#{item.reservationEnd}">
                                <f:convertDateTime pattern="MM/dd/yyyy" />
                            </h:outputText>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListReservationTitle_price}"/>
                            </f:facet>
                            <h:outputText value="#{item.price}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="&nbsp;"/>
                            </f:facet>
                            <h:commandLink action="#{reservationController.prepareView}" value="#{bundle.ListReservationViewLink}"/>
                            <h:outputText value=" "/>
                            <h:commandLink action="#{reservationController.prepareEdit}" value="#{bundle.ListReservationEditLink}" rendered="#{userRights.client}"/>
                            <h:outputText value=" "/>
                            <h:commandLink action="#{reservationController.destroy}" value="#{bundle.ListReservationDestroyLink}" rendered="#{userRights.client || userRights.moderator}"/>
                        </h:column>
                    </h:dataTable>
                </h:panelGroup>
                <br />
                <h:commandLink action="#{reservationController.prepareCreate()}" value="#{bundle.ListReservationCreateLink}" rendered="#{userRights.client}"/>
            </h:form>
        </ui:define>
    </ui:composition>

</html>
